﻿using Adalbertus.BudgetPlanner.Services;
using Adalbertus.BudgetPlanner.ViewModels.BudgetPlanning;
using Adalbertus.BudgetPlanner.ViewModels.ExpenseTypes;
using Adalbertus.BudgetPlanner.ViewModels.ExternalSources;
using Caliburn.Micro;
using System;

namespace Adalbertus.BudgetPlanner.ViewModels
{
    public class ShellViewModel : Conductor<IScreen>, IShell
    {
        private IWindowManager _windowManager;

        public ShellViewModel(IWindowManager windowManager)
        {
            _windowManager = windowManager;
            //ShowBudget();
#if DEBUG
            CreateDefaultData();
#endif
        }

        private void CreateDefaultData()
        {
            var cashFlowService = IoC.Get<ICashFlowService>();
            var jedzenieCF = cashFlowService.Create("Jedzenie");
            var chemiaCF = cashFlowService.Create("Chemia");

            var incomeService = IoC.Get<IIncomeService>();
            incomeService.Create("SMT Software");
            incomeService.Create("Kancelaria");

            var savingService = IoC.Get<ISavingService>();
            savingService.Create("Rezerwa");
            savingService.Create("Samochód");

            var budgetService = IoC.Get<IBudgetService>();
            var budget = budgetService.GenerateEmptyBudgetForNextMonth(DateTime.Now.AddMonths(-1));
            budget.AddExpense(jedzenieCF, 138.33M, "astra", DateTime.Now.AddDays(4));
            budget.AddExpense(chemiaCF, 20, "pasta do zębów", DateTime.Now);
            budgetService.Save(budget);
        }

        public void ShowPreviousBudget()
        {
            
        }

        public void ShowNextBudget()
        {

        }

        public void CreateNewBudgetPlan()
        {
            BudgetPlanViewModel budgetPlanViewModel = IoC.Get<BudgetPlanViewModel>();
            budgetPlanViewModel.CreateNewBudgetPlan();
            ActivateItem(budgetPlanViewModel);
        }

        public void ShowExpenseTypes()
        {
            ActivateItem(IoC.Get<ExpenseTypesViewModel>());
        }

        public void ShowExternalSources()
        {
            ActivateItem(IoC.Get<ExternalSourcesViewModel>());
        }
    }
}
